1.树莓派下载:https://www.raspberrypi.org/downloads/raspbian/
图1: 1.png

1.:/home/pi# wget https://nodejs.org/dist/latest-v10.x/node-v10.9.0-linux-armv7l.tar.gz


tar zxvf node-v10.9.0-linux-armv7l.tar.gz
cd node-v10.9.0-linux-armv7l
sudo cp bin/* /usr/bin/ -r
sudo cp include/ /usr/include/ -r
sudo cp lib/ /usr/lib/ -r
sudo cp share/ /usr/share/ -r
cd ..
node -v


// npm  问题
npm -v
bash: /usr/bin/npm: No such file or directory

root@raspberrypi:/usr/bin# find / -name "npm-cli.js"
/home/pi/node-v10.9.0-linux-armv7l/lib/node_modules/npm/bin/npm-cli.js
/usr/lib/lib/node_modules/npm/bin/npm-cli.js


find / -name "npm-cli.js"
ln -s /usr/lib/lib/node_modules/npm/bin/npm-cli.js /usr/bin/npm

// pm2
npm install -g pm2 

// ngixn  git

// 关机
sudo shutdown -h now
// 重启
sudo reboot

// 安装rpio
npm install rpio
node-gyp rebuild
阅读这里
https://github.com/TooTallNate/node-gyp#installation
还有这里
https://github.com/TooTallNate/node-gyp/issues/154
问题就解决了

sudo npm install -g node-gyp
sudo npm install rpio

// gcc
1.apt-get install gcc g++
2.编译：gcc -o hello hello.c
3.删除： apt-get remove gcc 

// wiringPi
git clone git://git.drogon.net/wiringPi
cd wiringPi
./build

编译:
gcc -Wall -o blink blink.c -lwiringPi
sudo ./blink

花生壳
1. wget http://download.oray.com/peanuthull/embed/phddns_rapi_3.0.2.armhf.deb
2. SN :RAPI7cac5498b054

IIC
 gpio load i2c
 gpio: Unable to load/unload modules as this Pi has the device tree enabled.
  You need to run the raspi-config program (as root) and select the
  modules (SPI or I2C) that you wish to load/unload there and reboot.

raspi-config  开启IIC  然后重启

/boot/config.txt
# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
#dtparam=i2s=on   ---> dtparam=i2s=on
dtparam=spi=on

gpio i2cdetect

apt-get install i2c-tools

https://blog.csdn.net/xukai871105/article/details/15029843
http://www.mamicode.com/info-detail-1791255.html
i2cdump -y 1 0x50
i2cset  -y 1 i2c设备地址 写入位置 写入内容
 i2cget -y 1 0x50 0x00
 
 Zm20180213  
 hgdq-2018  
 RAPI7cac5498b054 RAPI7cac00cce400
 
 hhk:RAPI7cac5498b054
 
 2x1l851569.51mypc.cn:53486


sudo apt-get --purge remove nginx

server {
  listen 80;
  server_name localhost;

  location / {
      root /home/pi/Desktop/vmail/dist;
      index index.html;
      try_files $uri $uri/ /index.html;
  }
}

重启：sudo reboot

~/.ssh

192.168.3.12 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBBXoNe3zbTVGAAGU1RQP1TSdj4964nEmrR5Z3RhDtvDRWtNjgR6fnqiNNigVBeA7YCMHNUt7NvaJtmf7+hL3M2M=

2020.07.26

系统开机
https://projects.raspberrypi.org/en/projects/raspberry-pi-setting-up

https://projects.raspberrypi.org/en/pathways/getting-started-with-raspberry-pi

安装vim就比较简单了：
sudo apt-get install vim

跟换镜像源

1.打开文件： vim /etc/apt/sources.list.d/raspi.list。 
2.修改成如下的内容： deb https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ jessie main ui


1.打开文件： vim /etc/apt/sources.list。 
2.修改成如下的内容： deb http://mirrors.aliyun.com/raspbian/raspbian/ stretch main contrib non-free rpi


修改完成之后，保存并退出，然后执行 apt-get update

https://www.jianshu.com/p/67b9e6ebf8a0

安装wiringPi
http://wiringpi.com/download-and-install/
y验证：https://blog.csdn.net/zhuming3834/article/details/81984594

安装node.js
https://blog.csdn.net/zhuming3834/article/details/81906935
https://nodejs.org/dist/latest/

1. 下载 wget https://nodejs.org/dist/latest-v14.x/node-v14.6.0-linux-armv7l.tar.gz
2. 解压 tar zxvf node-v14.6.0-linux-armv7l.tar.gz 
3. root@raspberrypi:/home/pi/Downloads/node-v14.6.0-linux-armv7l# ./bin/node -v 
    v14.6.0
4. 环境变量：
ln /home/pi/Downloads/node-v14.6.0-linux-armv7l/bin/node /usr/local/bin/node
ln -s /home/pi/Downloads/node-v14.6.0-linux-armv7l/lib/node_modules/npm/bin/npm /usr/local/bin/npm
5. vim /usr/local/bin/npm
6. 验证 
  node -v v14.6.0
  npm -v  6.14.6

  root@raspberrypi:/# node -v
  v14.6.0
  root@raspberrypi:/# npm -v
  6.14.6
  root@raspberrypi:/# 

function hello(){
  console.log('Hello World!');
}
hello();









安装花生壳
https://hsk.oray.com/download/
https://blog.csdn.net/zhuming3834/article/details/82114787
http://service.oray.com/question/2680.html
wget http://download.oray.com/peanuthull/embed/phddns_3.0.4_systemd.deb
dpkg -i phddns_3.0.4_systemd.deb

+--------------------------------------------------+
|           Oray PeanutHull Linux 3.0.4            |
+--------------------------------------------------+
|  SN: RAPI7cac5498b054   Default password: admin  |
+--------------------------------------------------+
|    Remote Management Address http://b.oray.com   |
+--------------------------------------------------+

启动 phddns start

打开80端口
一、查看iptables是否已安装
iptables --version
二、开启指定端口
# 开启80端口
iptables -I INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
iptables  -I OUTPUT -o eth0 -p tcp --sport 80 -j ACCEPT
http://www.feihu1996.cn/?id=289
无效？

https://www.cnblogs.com/yushuo/p/12018944.html


https://nodejs.org/dist/latest-v14.x/node-v14.6.0-linux-armv7l.tar.gz


安装node-rpio
sudo npm install rpio
root@raspberrypi:/# sudo npm install rpio 

> rpio@2.2.0 install /node_modules/rpio
> node-gyp rebuild

make: 进入目录“/node_modules/rpio/build”
  CXX(target) Release/obj.target/rpio/src/rpio.o
In file included from ../src/rpio.cc:17:
../../nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
../../nan/nan.h:2294:62: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
                                                              ^
In file included from ../../nan/nan.h:56,
                 from ../src/rpio.cc:17:
../src/rpio.cc: At global scope:
/root/.cache/node-gyp/14.6.0/include/node/node.h:745:43: warning: cast between incompatible function types from ‘void (*)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’ {aka ‘void (*)(v8::Local<v8::Object>)’} to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
       (node::addon_register_func) (regfunc),                          \
                                           ^
/root/.cache/node-gyp/14.6.0/include/node/node.h:779:3: note: in expansion of macro ‘NODE_MODULE_X’
   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
   ^~~~~~~~~~~~~
../src/rpio.cc:497:1: note: in expansion of macro ‘NODE_MODULE’
 NODE_MODULE(rpio, setup)
 ^~~~~~~~~~~
  CC(target) Release/obj.target/rpio/src/bcm2835.o
../src/bcm2835.c: In function ‘bcm2835_gpio_pad’:
../src/bcm2835.c:487:3: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
   if (bcm2835_pads == MAP_FAILED)
   ^~
../src/bcm2835.c:490:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
     volatile uint32_t* paddr = bcm2835_pads + BCM2835_PADS_GPIO_0_27/4 + group;
     ^~~~~~~~
../src/bcm2835.c: In function ‘bcm2835_gpio_set_pad’:
../src/bcm2835.c:500:3: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
   if (bcm2835_pads == MAP_FAILED)
   ^~
../src/bcm2835.c:503:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
     volatile uint32_t* paddr = bcm2835_pads + BCM2835_PADS_GPIO_0_27/4 + group;
     ^~~~~~~~
  SOLINK_MODULE(target) Release/obj.target/rpio.node
  COPY Release/rpio.node
make: 离开目录“/node_modules/rpio/build”
npm WARN saveError ENOENT: no such file or directory, open '/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/package.json'
npm WARN !invalid#1 No description
npm WARN !invalid#1 No repository field.
npm WARN !invalid#1 No README data
npm WARN !invalid#1 No license field.

+ rpio@2.2.0
added 4 packages from 9 contributors and audited 4 packages in 20.448s
found 0 vulnerabilities

+ rpio@2.2.0



安装
npm install -g pm2
https://blog.csdn.net/zhuming3834/article/details/82113078

root@raspberrypi:/home/pi/Desktop# npm install -g pm2
/usr/local/bin/pm2 -> /usr/local/lib/node_modules/pm2/bin/pm2
/usr/local/bin/pm2-dev -> /usr/local/lib/node_modules/pm2/bin/pm2-dev
/usr/local/bin/pm2-docker -> /usr/local/lib/node_modules/pm2/bin/pm2-docker
/usr/local/bin/pm2-runtime -> /usr/local/lib/node_modules/pm2/bin/pm2-runtime
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/pm2/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm"})

+ pm2@4.4.0
added 185 packages from 191 contributors in 110.002s

root@raspberrypi:/home/pi/Desktop# pm2 -v

                        -------------

__/\\\\\\\\\\\\\____/\\\\____________/\\\\____/\\\\\\\\\_____
 _\/\\\/////////\\\_\/\\\\\\________/\\\\\\__/\\\///////\\\___
  _\/\\\_______\/\\\_\/\\\//\\\____/\\\//\\\_\///______\//\\\__
   _\/\\\\\\\\\\\\\/__\/\\\\///\\\/\\\/_\/\\\___________/\\\/___
    _\/\\\/////////____\/\\\__\///\\\/___\/\\\________/\\\//_____
     _\/\\\_____________\/\\\____\///_____\/\\\_____/\\\//________
      _\/\\\_____________\/\\\_____________\/\\\___/\\\/___________
       _\/\\\_____________\/\\\_____________\/\\\__/\\\\\\\\\\\\\\\_
        _\///______________\///______________\///__\///////////////__


                          Runtime Edition

        PM2 is a Production Process Manager for Node.js applications
                     with a built-in Load Balancer.

                Start and Daemonize any application:
                $ pm2 start app.js

                Load Balance 4 instances of api.js:
                $ pm2 start api.js -i 4

                Monitor in production:
                $ pm2 monitor

                Make pm2 auto-boot at server restart:
                $ pm2 startup

                To go further checkout:
                http://pm2.io/


                        -------------

[PM2] Spawning PM2 daemon with pm2_home=/root/.pm2
[PM2] PM2 Successfully daemonized
4.4.0

pm2 start node_led.js 

root@raspberrypi:/home/pi/Desktop# pm2 start node_led.js 
[PM2] Applying action restartProcessId on app [node_led](ids: [ 0 ])
[PM2] [node_led](0) ✓
[PM2] Process successfully started
┌─────┬─────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name        │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼─────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0   │ node_led    │ default     │ N/A     │ fork    │ 28414    │ 0s     │ 0    │ online    │ 0%       │ 20.1mb   │ root     │ disabled │
└─────┴─────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
root@raspberrypi:/home/pi/Desktop# pm2 list
┌─────┬─────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name        │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼─────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0   │ node_led    │ default     │ N/A     │ fork    │ 28135    │ 6m     │ 0    │ online    │ 0%       │ 32.7mb   │ root     │ disabled │
└─────┴─────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
root@raspberrypi:/home/pi/Desktop# pm2 stop node_led
[PM2] Applying action stopProcessId on app [node_led](ids: [ 0 ])
[PM2] [node_led](0) ✓
┌─────┬─────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name        │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼─────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0   │ node_led    │ default     │ N/A     │ fork    │ 0        │ 0      │ 0    │ stopped   │ 0%       │ 0b       │ root     │ disabled │
└─────┴─────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘

